package com.hege.service.impl;

import com.hege.domain.SysUser;
import com.hege.mapper.SysUserDao;
import com.hege.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author hege
 * @Date 2020/11/22 21:53
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private SysUserDao sysUserDao;

    @Override
    public SysUser queryUserById(long id) {
        return sysUserDao.selectByPrimaryKey(id);
    }

    @Override
    @Transactional //开启事务
    public int updateUserById(SysUser user) {

        int i = sysUserDao.updateByPrimaryKeySelective(user);

        //出现异常
        int num = 1 / 0;

        return i;
    }
}
